<?php
/**
 * Smartyクラスを読み込み
 *
 */
require_once(SMARTY_LIB_PATH.'Smarty.class.php');

class SmartyMail {
	/**
	 * Smartyオブジェクト
	 *
	 * @var object
	 */
	protected $smarty = null;

	/**
	 * テンプレートファイル名
	 *
	 * @var string
	 */
	protected $templateFile = '';

	function __construct() {
		$this->smarty = new Smarty();
		$this->smarty->template_dir = SMARTY_TMP_PATH.'templates/mail/';
		$this->smarty->compile_dir = SMARTY_TMP_PATH.'templates_c/';
		$this->smarty->cache_dir = SMARTY_TMP_PATH.'cache/';
		$this->smarty->config_dir = SMARTY_TMP_PATH.'configs/';
	}

	public function setTemplate($fileName) {
		$this->templateFile = $fileName;
	}

	public function assign($objName, $valueObject) {
		$this->smarty->assign($objName, $valueObject);
	}
	public function sendMail($to, $subject, $from, $from_name) {
		$body = $this->smarty->fetch($this->templateFile);
		return sendmail_utf8($to, $subject, $body, $from, $from_name);
	}

}
